﻿@addTagHelper *, WebVella.Erp.Plugins.Core
@addTagHelper *, WebVella.Erp.Web

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@addTagHelper *, WebVella.TagHelpers

@using WebVella.Erp.Web.Components;
@using WebVella.Erp.Web.Models;

@{
	var options = (PcApplications.PcApplicationsOptions)ViewBag.Options;
	var apps = (List<App>)ViewBag.Apps;
}
<div class="row">
	@foreach (var app in apps)
	{
		var appUrl = "";
		if (app.HomePages.Count > 0)
		{
			appUrl = $"/{app.Name}/a/{app.HomePages[0].Name}";
		}
		else if (app.Sitemap != null && app.Sitemap.Areas.Count > 0)
		{
			foreach (var area in app.Sitemap.Areas)
			{
				if (area.Nodes.Count > 0)
				{
					appUrl = area.Nodes.First().Url;
					break;
				};
			}

		}
		var appDescription = app.Description ?? string.Empty;
		if (appDescription.Length > 85)
		{
			appDescription = app.Description.Substring(0, 85) + "...";
		}

		<div class="col-xl-3 col-lg-4 col-md-6">
			<div class="card app-card shadow-sm mb-3">
				<div class="card-body p-0">
					<div class="row no-gutters">
						<div class="col-lg-3">
							<div class="app-image-wrapper pt-5 pb-5 pt-lg-0 pb-lg-0" style="background-color:@(app.Color + "25")">
								<span class="app-icon @app.IconClass" style="color:@app.Color"></span>
							</div>
						</div>
						<div class="col-lg-9">
							<div class="app-meta p-3 p-lg-2">
								<h3 class="label">@app.Label</h3>
								<div class="description mb-2">@appDescription</div>
							</div>
						</div>
					</div>
					@if (!String.IsNullOrWhiteSpace(appUrl))
					{
						<a class="app-link" href="@appUrl"><em></em></a>
					}
				</div>
				<div class="card-footer">
					<div class="author go-gray">
						@if (String.IsNullOrWhiteSpace(appUrl))
						{
							<span class="float-right go-red"><span class="fas fa-info-circle"></span> Empty Sitemap</span>
						}
						else
						{
							@Html.Raw(app.Author)
						}
					</div>
				</div>
			</div>
		</div>
	}
</div>
@*<component type="typeof(HelloBoz)" render-mode="ServerPrerendered" param-Name="@("Boz")"/>

<script src="_framework/blazor.server.js" autostart="false"></script>
	<script>
		(function start() {
			Blazor.start({
				logLevel: 1, // LogLevel.Debug
				configureSignalR: builder => builder.configureLogging("debug") // LogLevel.Debug
			});
		})()
	</script>
<script>
  window.handleTickerChanged = () => {
	console.log("log");
  };
</script>*@
